﻿using Architecture.Domain.Dto;
using Architecture.Domain.RBAC;
using Architecture.Service;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Architecture.Api.Controllers
{
    /// <summary>
    /// 请假Api控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LeaveController : ControllerBase
    {
        protected readonly ILeaveService leaveService;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="leaveService"></param>
        public LeaveController(ILeaveService leaveService)
        {
            this.leaveService = leaveService;
        }
        /// <summary>
        /// 部门领导
        /// </summary>
        /// <param name="sectorid"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<UserInfo>> Leading(int sectorid)
        {
            var list = await leaveService.Leading(sectorid);
            return list;
        }
        /// <summary>
        /// 请假表添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> LeaveAdd(Leaved model)
        {
            return await leaveService.LeaveAdd(model);
        }
        /// <summary>
        /// 请假列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageListDto<Leaved>> GetLeading(int pageIndex, int pageSize, string? userName)
        {
            var list = await leaveService.GetLeading(pageIndex,pageSize,userName);
            return list;
        }
        /// <summary>
        /// 请假真删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<int> LeaveDelete(int id)
        {
            var list = await leaveService.LeaveDelete(id);
            return list;
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Leaved> GetLeaved(int id)
        {
            var list = await leaveService.GetLeaved(id);
            return list;
        }
        /// <summary>
        /// 审批状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> VettingLeave(Leaved model)
        {
            var leavelist = await leaveService.VettingLeave(model);
            return leavelist;
        }
    }
}
